window.onload = async function(){
  const res = await axios({ url: '/dashboard' })
  console.log(res);
  for (let key in res.data.overview) {

    document.querySelector(`[name="${key}"]`).innerHTML = res.data.overview[key]
  }
  renderSubject() 
}


function renderSubject() {
var myChart = echarts.init(document.getElementById('line'));

// 指定图表的配置项和数据
  var option = {
    title: { text: '2022全学科薪资' },
    xAxis: {
      type: 'category',
      data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    axisLine: {
      lineStyle: {
        type: "dashed",
        color: 'skyblue'
      }
    },
    axisLabel: {
      color: '#000'
    },
    yAxis: {
      type: 'value',
      splitLine: {
        lineStyle: {
          type: "dashed",
          color: 'skyblue'
        }
      },
    },
    series: [
      {
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line',
        smooth: true,
        lineStyle: {
          width: 8,
          color: '#5f8eff'
        }
      }
    ]
  }
// 使用刚指定的配置项和数据显示图表。
  myChart.setOption(option);
}



function renderSubject(nb) {
  var myChart = echarts.init(document.getElementById('gender'));
  
  // 指定图表的配置项和数据
  var option = {
    title: [
      {
        text: '男女薪资分布'
      },
      {
        text: '男生',
        left: '50%',
        top: '40%',
        textAlign: 'center'
      },
      {
        text: '女生',
        left: '50%',
        top: '90%',
        textAlign: 'center'
      },
    ],
    tooltip: {
      trigger: 'item'
    },
       
    series: [
      {
        name: 'Access From',
        type: 'pie',
        radius: ['15%', '25%'],
        data: [
          { value: 1048, name: 'Search Engine' },
          { value: 735, name: 'Direct' },
          { value: 580, name: 'Email' },
          { value: 484, name: 'Union Ads' },
          { value: 300, name: 'Video Ads' }
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        },
        center: ['50%', '20%'],
      },
       
         
      {
        name: 'Access From',
        type: 'pie',
        radius: ['15%', '25%'],
        data: [
          { value: 1048, name: 'Search Engine' },
          { value: 735, name: 'Direct' },
          { value: 580, name: 'Email' },
          { value: 484, name: 'Union Ads' },
          { value: 300, name: 'Video Ads' }
        ],
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        },
        center: ['50%', '70%'],
      }
    ]
  }
  // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
  }